import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user',
  () => {
    const phone = ref(null);

    function setPhone(new_phone) {
      phone.value = new_phone
    }

    return { phone, setPhone }
  },
  // 本地持久化存储
  {
    persist: [
      {
        enabled: true,
        strategies: [
          {
            paths: ['phone'],
            storage: localStorage
          }
        ]
      }
    ]
  }
);


export const useArticleStore = defineStore('article',
  () => {
    const title = ref(null);

    function setTitle(new_title) {
      title.value = new_title
    }

    return { title, setTitle }
  },
  // 本地持久化存储
  {
    persist: [
      {
        enabled: true,
        strategies: [
          {
            paths: ['title'],
            storage: localStorage
          }
        ]
      }
    ]
  }
)
